﻿using System;
using System.Collections.Generic;
using FlowCanvas;
using FlowCanvas.Nodes;
using LogSystem;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class StreetEventOnPropItemTakenEvent : EventNode
    {
        public static Action<int, int,PropItem> OnPropItemTaken;
        
        private FlowOutput onPropItemTakenEvent;
        private int itemId;
        private int type;
        private int uniqueId;
        private int parameter_01;
        
        protected override void RegisterPorts()
        {
            onPropItemTakenEvent = AddFlowOutput("onPropItemTaken");
            AddValueOutput<int>("itemId", () => { return itemId; });
            AddValueOutput<int>("uniqueId", () => { return uniqueId; });
            AddValueOutput<int>("type", () => { return type; });
            AddValueOutput<int>("parameter_01", () => { return parameter_01; });
        }

        public override void OnGraphStarted()
        {
            OnPropItemTaken += OnPropItemTakenFunc;
        }

        public override void OnGraphStoped()
        {
            OnPropItemTaken -= OnPropItemTakenFunc;
        }

        private void OnPropItemTakenFunc(int itemId, int uniqueId,PropItem propItem)
        {
            this.itemId = itemId;
            this.uniqueId = uniqueId;
            this.type = propItem.ItemType;
            parameter_01 = propItem.ItemConfig.parameter_01;
            onPropItemTakenEvent.Call(new Flow());
        }
    }
}